package com.holi.hiteacher.utils;

import android.view.View;
import android.widget.AbsListView;

import com.joshua.xlistview.XListView;

/**
 * @description:
 * @author: JoshuaWong E-mail:joshuawongchn@gmail.com
 * @date: 2016年12月23日 22:22
 * @version: 1.0
 */
public abstract class HidingScrollListener implements XListView.OnXScrollListener {
    private boolean visible = true;

    @Override
    public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int
            totalItemCount) {
        if (!visible && firstVisibleItem < 3) {
            visible = true;
            onShow();
        }
        if (visible && firstVisibleItem >= 3) {
            visible = false;
            onHide();
        }
    }

    @Override
    public void onXScrolling(View view) {
    }

    @Override
    public void onScrollStateChanged(AbsListView view, int scrollState) {
    }

    public abstract void onHide();

    public abstract void onShow();
}